<template>
  <div class="app-container">
    <el-row type="flex" class="row-bg" justify="space-between">
      <el-col :span="6"><div class="title">编辑任务</div></el-col>
      <el-col :span="6">
        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
        <el-button @click="resetForm('ruleForm')">取消</el-button>
      </el-col>
    </el-row>
    <el-form
      ref="ruleForm"
      :model="ruleForm"
      :rules="rules"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="任务名称" prop="name">
        <el-input v-model="ruleForm.name" placeholder="请输入内容" />
      </el-form-item>
      <el-form-item label="描述" prop="description">
        <el-input
          v-model="ruleForm.description"
          type="textarea"
          :rows="2"
          placeholder="请输入内容"
        />
      </el-form-item>
      <el-form-item label="截止日期" prop="end_date">
        <el-date-picker
          v-model="ruleForm.end_date"
          type="date"
          placeholder="选择日期"
          format="yyyy-MM-dd"
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// import * as task from '@/api/task'
export default {
  data() {
    return {
      ruleForm: {
        name: '',
        description: '',
        end_data: '2020-09-09'
      },
      rules: {
      }
    }
  },
  mounted() {
    this.ruleForm.end_data = this.$route.query.row.end_data
    console.log(this.ruleForm.end_data)
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          // task.edit(this.ruleForm).then(response => {
          //   console.log(response)
          //   this.$message({
          //     message: '操作Success',
          //     type: 'success'
          //   })
          // })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>
<style>
.title{
  font-family: Noto Sans SC;
  font-size: 22px;
  font-style: normal;
  font-weight: 500;
  line-height: 30px;
  letter-spacing: 0px;
  text-align: left;
  height: 72px;
  margin: 0px 20px;
}
</style>
